import { defineStore } from 'pinia'
import { getMedicineList,deleteMedicine,addMedicine,saveDrugGroup } from '@/api/medicineHttp'
import { showLoading } from '../utils/loading';

// 所有药品
export const useMedicineStore = defineStore('medicine', {
  state: () => ({
    medicines: [],
    page: 1,
    pageSize: 10,
    total:0,
    hasMore: true,
    isLoading: false
  }),
  
  getters: {
    
  },
  
  actions: {
    async getMedicineList() {
      await getMedicineList()
      return
      console.log('第三步在medicine.js中请求药品数据');
      const {data:{data}} = await getMedicineList(this.page,this.pageSize)
      console.log(data);
      
        // 显示加载中
        // $http.beforeRequest()        
        // 隐藏加载提示
    },
    async deleteMedicine(id){
      await deleteMedicine(id)
    },
    async addMedicine(medicine){
      await addMedicine(medicine)
    },
    async saveDrugGroup(group){
      await saveDrugGroup(group)
    }
  }
}) 